<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateUserAddressesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('user_addresses', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->bigInteger('user_id')->comment('users表ID');
            $table->string('title', 50)->nullable()->comment('地址标题，类似标签');
            $table->string('name', 60)->comment('收货人姓名');
            $table->string('mobile', 11)->comment('收货人手机号');
            $table->string('area_code', 10)->comment('地址的编码，由前端地址库时传递');
            $table->string('country', 30)->default('中国');
            $table->string('province', 30);
            $table->string('city', 30);
            $table->string('county', 30)->comment('收货人所在地区，县级单位');
            $table->string('detail', 120)->comment('详细地址');
            $table->string('postal_code', 60)->nullable()->comment('邮编');
            $table->tinyInteger('is_default')->default(0)->comment('是否默认地址');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('user_addresses');
    }
}
